using System.Security.Principal;

namespace Jsdl.Service
{
    public class JsdlPrincipal : IPrincipal
    {
        private readonly AuthenticatedJsdlServicesHandlerBase handler; 
        public IIdentity Identity { get; private set; }

        public JsdlPrincipal(AuthenticatedJsdlServicesHandlerBase handler, string username)
        {
            this.handler = handler; 
            Identity = new JsdlIdentity { Name = username };
        }

        public bool IsInRole(string role)
        {
            return handler.IsUserInRole(Identity.Name, role);
        }
    }
}